package com.emm.yixun.website.service.marketing;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.emm.yixun.common.model.BusinessAbnorma;
import com.emm.yixun.common.model.dto.BusinessAbnormaDto;
import com.emm.yixun.common.response.ResponseList;
import com.emm.yixun.marketing.service.BusinessAbnormaServiceFacade;

@Service
public class BusinessAbnormaServiceImpl implements BusinessAbnormaService {
	
	@Autowired
	private BusinessAbnormaServiceFacade businessAbnormaServiceFacade;

	@Override
	public boolean isPassBusiness(Long businessId, String businessType) {
		BusinessAbnormaDto businessAbnormaDto = new BusinessAbnormaDto();
		businessAbnormaDto.setBusinessId(businessId);
		businessAbnormaDto.setBusinessType(businessType);
		ResponseList<BusinessAbnorma> responseList = businessAbnormaServiceFacade.findByDto(businessAbnormaDto);
		if(responseList.isSuccess()){
			if(responseList.getEntity()!=null&&responseList.getEntity().size()!=0){
				return true;
			}else{
				return false;
			}
		}else{
			return false;
		}
	}

	@Override
	public BusinessAbnorma isPassBusinessReturnId(Long businessId, String businessType) {
		BusinessAbnormaDto businessAbnormaDto = new BusinessAbnormaDto();
		businessAbnormaDto.setBusinessId(businessId);
		businessAbnormaDto.setBusinessType(businessType);
		ResponseList<BusinessAbnorma> responseList = businessAbnormaServiceFacade.findByDto(businessAbnormaDto);
		if(responseList.isSuccess()){
			if(responseList.getEntity()!=null&&responseList.getEntity().size()!=0){
				return responseList.getEntity().get(0);
			}else{
				return null;
			}
		}else{
			return null;
		}
	}

}
